﻿#pragma once

#include "common.h"
#include "font.h"
#include <vector>

namespace anip
{
	class Font;
	class Texture2D;

	class Draw
	{
		friend class Context;

	private:
		struct Impl;

		static void _init();

	public:
		struct DashOption
		{
			DashOption() {}
			float unitLength = -1;
			float solidLength = -1;
			float start = 0;
		};

		static void unitSquareShape();
		static void rect(invec2 pos, invec2 size, const color& fill);
		static void ellipse(invec2 pos, invec2 size, const color& fill);
		static void roundedRect(invec2 pos, invec2 size, float rad, const color& fill);

		static void rectOutline(invec2 pos, invec2 size, 
			float wid = 1.0f, const color& col = Colors::black);
		static void roundedRectOutline(invec2 pos, invec2 size, float rad,
			float wid = 1.0f, const color& col = Colors::black);
		static void ellipseOutline(invec2 pos, invec2 size, 
			float wid = 1.0f, const color& col = Colors::black);
		static void arc(invec2 pos, invec2 size, float start, float end,
			float wid = 1.0f, const color& col = Colors::black);

		static void shadowRect(invec2 pos, invec2 size, const color& fill, float blur);

		static void line(invec2 p1, invec2 p2, float wid = 1.0f,
			const color& col = Colors::black, const DashOption& dash = DashOption());

		static void polyline(const vec2* pts, int n, float wid = 1.0f,
			const color& col = Colors::black, const DashOption& dash = DashOption());

		static void crossMarker(invec2 pos, float size = 2.0f,
			float wid = 1.0f, const color& color = Colors::black);

		static void texture(invec2 pos, const Texture2D& tex,
			const color& tint = Colors::white);

		// ANIP_TODO: offset, and scaling or viewSize maybe? enable tiling anyway
		static void texture(invec2 pos, invec2 size,
			const Texture2D& tex,
			const color& tint = Colors::white);

		static void textureHDR(invec2 pos, invec2 size,
			const Texture2D& tex,
			const color& tint = Colors::white, bool markOutOfRange = false);

		static void text(invec2 pos, invec2 size,
			const Texture2D& tex, const color& col);

		static void text(invec2 pos, const wstring& str,
			const color& col, const Font& f, invec2 align = { 0, 0 });

		static void text(invec2 pos, const wstring& str,
			const color& col, const Font& f, invec2 align,
			const TextRenderer::Options& opt);
	};
}